package com.itany.shop.rowmapper;

import com.itany.shop.entity.Order;
import com.itany.shop.entity.User;
import com.itany.shop.util.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author Miss Chen
 * @version 1.0
 * @date 2024年08月16日16:25
 */
public class OrderRowMapper implements RowMapper {
    @Override
    public Object mapRow(ResultSet rs) throws SQLException {
        Order order=new Order();
        order.setId(rs.getInt("id"));
        order.setNo(rs.getString("no"));
        order.setPrice(rs.getDouble("price"));
        User user=new User();
        user.setId(rs.getInt("user_id"));
        order.setUser(user);
        return order;
    }
}
